
import { queryConsumerCode, queryPretime, queryStoreDetail, queryStoreOptionList } from '@/services/store';
import { isEmpty } from '@/utils/common';

// 当前门店的相关信息
export default {
  namespace: 'currentstore',
  state: {
    currentstore: {}
  },

  effects: {
    *fetchCurrentStoreDetail({ payload }: any, { call, put }: IDvaOperation) {
      if(isEmpty(payload.braId)) return;
      const response = yield call(queryStoreDetail, payload.braId);
      if (isEmpty(response)) return false;
      yield put({
        type: 'saveStoreDetail',
        payload: response.data || {},
      });
    },
  },

  reducers: {
    saveStoreDetail(state: any, action: any) {
      return {
        ...state,
        currentstore: action.payload
      }
    },
    clearStoreDetail(state: any, action: any){
      return {
        ...state,
        currentstore: {}
      }
    }
  },
}